<template>
	<view>
		<view class="">
			<scroll-view scroll-x class="bg-white nav">
				<view class="flex text-center">
					<view class="cu-item flex-sub" :class="index==TabCur?'text-blue cur':''" v-for="(item,index) in tabs" :key="index" @tap="tabSelect(index)">
						{{item.name}}
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="">
			<swiper class="swiper" :style="'height:calc(100vh - 100px);'" :current="TabCur" :indicator-dots="false" @change="swipChange">
				<swiper-item v-for="(item, index) in tabs" :key="index">
					<publist :state="item.type" :timastap="timastap"></publist>
				</swiper-item>
			</swiper>
		</view>
		
		<!--
		<image src="../../static/pub.png" mode="" style="width: 100vw;"></image>

		<view class="cu-list grid col-2 no-border padding margin">
			<view class="cu-item" @click="open(1)">
				<view class='bg-orange ' style='width:12vw;height:12vw;margin:0 auto;border-radius:50%'>
					<view class="cuIcon-people text-white"></view>
				</view>
				<text>发布招聘信息</text>
			</view>
			<view class="cu-item" @click="open(0)">
				<view class='bg-yellow' style='width:12vw;height:12vw;margin:0 auto;border-radius:50%'>
					<view class="cuIcon-card text-white"></view>
				</view>
				<text>发布求职信息</text>
			</view>
		</view>

		<view class="text-center text-sm text-gray" style="position: fixed;width: 100vw;bottom: 70px;">
			专招驾驶员 -- 因为专注，所以更专业
		</view>
		-->
		<view class="padding bottom-pub"  >
			<button @tap="pub" class="bg-blue sm">新增发布</button>
		</view>
		
		
	</view>
</template>

<script>
	import {location} from '../../utils/util.js'
	import publist from "../../components/publist2.vue";
	
	export default {
		data() {
			return {
				timastap: '',
				tabs: [
					{name: '全部', type: '0'}, 
					{name: '展示中', type: '1'}, 
					{name: '审核中', type: '2'},
					{name: '已关闭', type: '3'},
					{name: '已拒绝', type: '4'},
				],
				TabCur: 0,
				showModal:false,
			};
		},
		onLoad(options) {
		},
		onShow() {
			this.timastap = new Date().getTime()+''
			// uni.showLoading({
			// 	mask: true,
			// 	title: '请稍候...'
			// })
			this.log();
		},
		components: {
			publist
		},
		methods: {
			tabSelect(index) {
				this.TabCur = index;
			},
			// 滑动 change
			swipChange(e){
				this.TabCur = e.detail.current;
			},
			log(){
				// 记录活跃和定位信息
				let data = location();
				let _this = this
				this.baseRequest('api/dau/log', 'GET', {}, function(res, info) {
					_this.baseRequest('api/dau/log/user', 'POST', {areaName: data.attenCity, address: data.address}, function(res, info) {
					}, function(){});
				}, function(){});
			},
			pub(){
				let self = this;
				uni.showActionSheet({
				    itemList: ['发布招聘信息', '发布求职信息'],
				    success: function (res) {
				        if(1 == res.tapIndex){
							self.open(0)
						}else{
							self.open(1)
						}
				    },
				    fail: function (res) {
				        
				    }
				});
			},
			open: function(type) {
				/*
				if(1 == type){
					uni.navigateTo({
						url: '/pages/pub/history'
					})
					return
				}*/
				uni.navigateTo({
					url: '/pages/pub/recpub?type=' + type
				})
			},
		}
	}
</script>

<style>

</style>
